package com.demoReflect;

import java.lang.reflect.Field;

public class test2Field {
    
    public static void main(String[] args) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
        Class c1 = Student.class;
        Field[] f1 = c1.getDeclaredFields();
        for (Field f : f1) {
            System.out.println(f.getName()+"------>"+f.getType());
        }
        
        Student stu = new Student();
        Field fid = c1.getDeclaredField("id");
        fid.setAccessible(true);
        fid.set(stu,123); //--------------------set
        System.out.println(stu.getId());
        System.out.println((Integer)fid.get(stu));//---get
        

    }
}
